package cn.edu.tju.elm.mapper;

import cn.edu.tju.core.model.Transaction;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface WalletTransactionMapper extends BaseMapper<Transaction> {
    
    @Select("SELECT * FROM t_transaction WHERE user_id = #{userId} ORDER BY created_at DESC LIMIT #{offset}, #{limit}")
    List<Transaction> selectByUserId(@Param("userId") Integer userId, 
                                     @Param("offset") Integer offset, 
                                     @Param("limit") Integer limit);
    
    @Select("SELECT * FROM t_transaction WHERE wallet_id = #{walletId} ORDER BY created_at DESC LIMIT #{offset}, #{limit}")
    List<Transaction> selectByWalletId(@Param("walletId") Long walletId, 
                                       @Param("offset") Integer offset, 
                                       @Param("limit") Integer limit);
    
    @Select("SELECT * FROM t_transaction WHERE wallet_id = #{walletId} AND type = #{type} ORDER BY created_at DESC")
    List<Transaction> selectByWalletIdAndType(@Param("walletId") Long walletId, @Param("type") String type);
}